#include <bits/stdc++.h>    
using namespace std;
double eps=1e-6;
int t,n,m,l,V,d[100005],v[100005],a[100005],p[100005],tg[10005],cnt;
bitset<3005> g[3005];
double c[100005];
double distance(int v0,int a,int t){
    return t*v0+0.5*a*t*t;
}
double speed(int v0,int a,int t){
    return sqrt(v0*v0+2*a*distance(v0,a,t));
}
bool cmp(bitset<3005> a,bitset<3005> b){
    for(int i = 3004;i>=1;i--)if(a[i]!=b[i])return a[i]>b[i];
    return 0;
}
int main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin  >> t;
    while(t--){
        cin >> n >> m >> l >> V ;
        for(int i = 1;i <= n;i++){
            cin >> d[i] >> v[i] >> a[i];
            c[i]=(double)(V*V-v[i]*v[i])/2.000/(double)a[i];
        }
        for(int i = 1;i <= m;i++){
            cin >> p[i];
            for(int j = 1;j <= n;j++){
                if((a[j]>0&&c[j]+eps<=(double)p[i])||(a[j]<0&&c[j]-eps>=(double)p[i]))g[i][j]=1,cnt+=!tg[j],tg[j]=1;
            }
        }
        cout << cnt << endl;
        //cal-1
        sort(g+1,g+m+1,cmp);        int ans1=0;
        bitset<3005> bq;
        for(int i = 2;i <= n;i++){
            if((bq|g[i])!=bq)ans1++,bq|=g[i];
        }
        //cal-2
        int ans2=0;
        bitset<3005> bbq;
        for(int i = 1;i <= n;i++){
            if((bbq|g[i])!=bbq)ans2++,bq|=g[i];
        }
        int ans=min(ans1,ans2);
        cout << ans << endl;
    }
    return 0;
}